<?php

/**
 * HalalmenuRestaurant filter form base class.
 *
 * @package    halalmenu_dev
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseHalalmenuRestaurantFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'namerestaurant'                    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'phone'                             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'mobile'                            => new sfWidgetFormFilterInput(),
      'fax'                               => new sfWidgetFormFilterInput(),
      'owner'                             => new sfWidgetFormFilterInput(),
      'email'                             => new sfWidgetFormFilterInput(),
      'website'                           => new sfWidgetFormFilterInput(),
      'nbseats'                           => new sfWidgetFormFilterInput(),
      'description'                       => new sfWidgetFormFilterInput(),
      'certification'                     => new sfWidgetFormFilterInput(),
      'street1'                           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'street2'                           => new sfWidgetFormFilterInput(),
      'crossstreet'                       => new sfWidgetFormFilterInput(),
      'zipcode'                           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'is_activated'                      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'idcity'                            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('HalalmenuCity'), 'add_empty' => true)),
      'transportation'                    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'hasMenu'                           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'url_fb'                            => new sfWidgetFormFilterInput(),
      'url_twitter'                       => new sfWidgetFormFilterInput(),
      'likefb'                            => new sfWidgetFormFilterInput(),
      'typeservice'                       => new sfWidgetFormFilterInput(),
      'budgetPrice'                       => new sfWidgetFormFilterInput(),
      'created_at'                        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'                        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'halalmenu_restaurant_cuisine_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'HalalmenuRestaurant')),
      'cuisines_list'                     => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'HalalmenuRestaurant')),
    ));

    $this->setValidators(array(
      'namerestaurant'                    => new sfValidatorPass(array('required' => false)),
      'phone'                             => new sfValidatorPass(array('required' => false)),
      'mobile'                            => new sfValidatorPass(array('required' => false)),
      'fax'                               => new sfValidatorPass(array('required' => false)),
      'owner'                             => new sfValidatorPass(array('required' => false)),
      'email'                             => new sfValidatorPass(array('required' => false)),
      'website'                           => new sfValidatorPass(array('required' => false)),
      'nbseats'                           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'description'                       => new sfValidatorPass(array('required' => false)),
      'certification'                     => new sfValidatorPass(array('required' => false)),
      'street1'                           => new sfValidatorPass(array('required' => false)),
      'street2'                           => new sfValidatorPass(array('required' => false)),
      'crossstreet'                       => new sfValidatorPass(array('required' => false)),
      'zipcode'                           => new sfValidatorPass(array('required' => false)),
      'is_activated'                      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'idcity'                            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('HalalmenuCity'), 'column' => 'id')),
      'transportation'                    => new sfValidatorPass(array('required' => false)),
      'hasMenu'                           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'url_fb'                            => new sfValidatorPass(array('required' => false)),
      'url_twitter'                       => new sfValidatorPass(array('required' => false)),
      'likefb'                            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'typeservice'                       => new sfValidatorPass(array('required' => false)),
      'budgetPrice'                       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'created_at'                        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'                        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'halalmenu_restaurant_cuisine_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'HalalmenuRestaurant', 'required' => false)),
      'cuisines_list'                     => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'HalalmenuRestaurant', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('halalmenu_restaurant_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function addHalalmenuRestaurantCuisineListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.HalalmenuRestaurantCuisine HalalmenuRestaurantCuisine')
      ->andWhereIn('HalalmenuRestaurantCuisine.idrestaurant', $values)
    ;
  }

  public function addCuisinesListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.HalalmenuRestaurantCuisine HalalmenuRestaurantCuisine')
      ->andWhereIn('HalalmenuRestaurantCuisine.id', $values)
    ;
  }

  public function getModelName()
  {
    return 'HalalmenuRestaurant';
  }

  public function getFields()
  {
    return array(
      'id'                                => 'Number',
      'namerestaurant'                    => 'Text',
      'phone'                             => 'Text',
      'mobile'                            => 'Text',
      'fax'                               => 'Text',
      'owner'                             => 'Text',
      'email'                             => 'Text',
      'website'                           => 'Text',
      'nbseats'                           => 'Number',
      'description'                       => 'Text',
      'certification'                     => 'Text',
      'street1'                           => 'Text',
      'street2'                           => 'Text',
      'crossstreet'                       => 'Text',
      'zipcode'                           => 'Text',
      'is_activated'                      => 'Number',
      'idcity'                            => 'ForeignKey',
      'transportation'                    => 'Text',
      'hasMenu'                           => 'Number',
      'url_fb'                            => 'Text',
      'url_twitter'                       => 'Text',
      'likefb'                            => 'Number',
      'typeservice'                       => 'Text',
      'budgetPrice'                       => 'Number',
      'created_at'                        => 'Date',
      'updated_at'                        => 'Date',
      'halalmenu_restaurant_cuisine_list' => 'ManyKey',
      'cuisines_list'                     => 'ManyKey',
    );
  }
}
